import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../routers/application.dart';

class HomeSwiper extends StatelessWidget {
  final List slides;
  const HomeSwiper({this.slides});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: ScreenUtil().setWidth(750),
      height: ScreenUtil().setHeight(353),
      child: Swiper(
        itemCount: slides.length,
        itemBuilder: (BuildContext context, int index) {
          return InkWell(
              onTap: () {
                Application.router.navigateTo(
                    context, '/detail?id=${slides[index]['goodsId']}');
              },
              child: Image.network(
                slides[index]['image'],
                fit: BoxFit.fill,
              ));
        },
        pagination: new SwiperPagination(),
        autoplay: true,
      ),
    );
  }
}
